import nltk
import os
from configs import NLTK_DATA_PATH

# 确保路径使用正确的格式
NLTK_DATA_PATH = os.path.abspath(NLTK_DATA_PATH)  # 标准化路径格式
os.makedirs(NLTK_DATA_PATH, exist_ok=True)  # 创建目录

print("NLTK_DATA_PATH:", NLTK_DATA_PATH)

# 将自定义路径插入到最前面
nltk.data.path.insert(0, NLTK_DATA_PATH)
# 或替换整个列表顺序
# nltk.data.path = [NLTK_DATA_PATH] + nltk.data.path

print("nltk.data.path:", nltk.data.path)
print("Downloading nltk data...")

# 显式指定下载目录
nltk.download('punkt_tab', download_dir=NLTK_DATA_PATH)